#include "LinkedList.h"

void Nodelist::additem(string FName,string LName, int CNumber,float AB)

{  
	//Node* newNode = new Node;         //newNode = add new node at the end of the list

	//newNode->m_pHeadName = FName;
	//newNode->LastName = LName;
	//newNode->customerNUmber = CNumber;
	//newNode->AccntBalance = AB;

	//newNode->pNext = m_pHead;   
	//m_pHead = newNode;               

	additem( new Node(FName,LName,CNumber,AB) );
}  
Nodelist::~Nodelist( void )
{
cout<<"destructor called"<<endl;
}
Node* Nodelist::GetTopNode(void) const
{
return m_pHead;

}
void Nodelist::display( void )             
{  
	Node* current = m_pHead;            
	while( current != NULL ){  
		
		cout <<"m_pHead Name: " <<" "<<current->m_pHeadName<<" Last Name: "<<current->LastName<<endl
			<<"Customer NUmber : "<<current->customerNUmber<<" Accnt Ballance : "<<current->AccntBalance
			<<endl;

		current = current->pNext;       
	}  
}  


void Nodelist::RemoveTopNode( void )//having problems
{
	if ( m_pHead == NULL )
		return; // or NULL

	Node *pTempNode = m_pHead;
	m_pHead = m_pHead->pNext;

	delete pTempNode;
	--size;
}



void Nodelist::SortCustNum(void)
{
int i,j,m,n=0,hold;
  Node *q, *p, *t;
  for(Node*q = m_pHead ; q ; q=q->pNext)   
 ++n ;  //;
 
  for(i=1 , t = m_pHead  ; i<=n-1 ;  t = t->pNext , ++i)
    for( j=0 , p = m_pHead  ; j<n-i ;  p = p->pNext , ++j)
       if(p->customerNUmber > (p->pNext)->customerNUmber)
       {
	 hold = p->customerNUmber;
         p->customerNUmber = (p->pNext)->customerNUmber;
         (p->pNext)->customerNUmber = hold;
       }

}
void Nodelist::additem(Node *pNode)
{
pNode->pNext = m_pHead;
m_pHead = pNode;
++size;


}